package yunquan.wang.base.spring.security;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.annotation.Resource;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.stereotype.Service;

import yunquan.wang.modules.base.dao.RolesAuthorityDao;
import yunquan.wang.modules.base.entity.RolesAuthority;
@Service
public class SecurityService {
	@Resource
private	RolesAuthorityDao  rolesAuthorityDao;
	public Set<GrantedAuthority> getRoleAuthority(String rolesId)
	{
		Set<GrantedAuthority> gaSet=new HashSet<GrantedAuthority>();
		List<RolesAuthority> raList =rolesAuthorityDao.findByRolesinfoId(rolesId);
		for(RolesAuthority ra:raList)
		{
			GrantedAuthorityRulesImpl impl=new GrantedAuthorityRulesImpl(ra.getAuthority().getName());
			impl.setRulesInfo(ra.getRulesInfos());
			gaSet.add(impl);
		}
		return gaSet;
	}

}
